#!/bin/bash
xhost +
HERE=$(dirname $(realpath $0))
source /opt/bashimport/transhell.sh
load_transhell_debug
if [ "$UID" != "0" ]; then
    pkexec $0 $@
    exit $?
fi
if command -v aptss;then
APT_CMD=aptss
else
APT_CMD=/usr/bin/apt
fi




confirm_installation() {
    garma --question --width=300 --height=150 --text="${TRANSHELL_CONTENT_PREPAREING_INSTALL} ${1}\n\n${TRANSHELL_CONTENT_PLEASE_CONFIRM_INSTALL}"
    return $?
}



    for APP in "$@"; do

        # 弹出确认窗口
        if confirm_installation "$APP"; then
            (   ${APT_CMD} update
                ${APT_CMD} install "$APP" --reinstall -y 
            if [ "$?" = "0" ]; then
                echo "---------------------------------------------------------------------------"
                echo "Info: $APP ${TRANSHELL_CONTENT_INSTALL_FINISHED}" 
            else
                echo "---------------------------------------------------------------------------"
                echo "Err: $APP ${TRANSHELL_CONTENT_INSTALL_ERROR}" 
            fi

            )| zenity --text-info --width=500 --height=300 --title="${TRANSHELL_CONTENT_INSTALL_LOG}" --auto-scroll

        else
        continue
        fi
        
    done
